package com.gustuy.learn1;

import java.io.IOException;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;

public class TCPClient {
    public static void main(String[] args) {
        Socket socket = null;
        InetAddress inetAddress;
        OutputStream os=null;
        int port=50010;
        {
            try {
                inetAddress = InetAddress.getByName("localhost");
                socket = new Socket("localhost", port);
                os = socket.getOutputStream();
                os.write("你好".getBytes());
            } catch (Exception e) {
                e.printStackTrace();
            }finally {
                try {
                    os.close();
                    socket.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
